package com.kingwang.training.designpattern.proxy.bo;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

@Service
public class ProxyPaymentService implements PaymentService {
    private PaymentService paymentService;

    public ProxyPaymentService(@Qualifier("wechatPaymentService") PaymentService paymentService) {
        this.paymentService = paymentService;
    }

    @Override
    public void pay() {
        beforePay();
        this.paymentService.pay();
        afterPay();
    }

    private void afterPay() {
        System.out.println("after pay");
    }

    private void beforePay() {
        System.out.println("before pay");
    }

}
